<?php
/**
 * Created by PhpStorm.
 * User: 64423
 * Date: 2018/10/24
 * Time: 15:06
 */

namespace app\shop\model;


use think\Model;

class OrderModel extends Model
{
    protected $table = 'dp_order';
    protected $field = true;

    public function user()
    {
        return $this->hasOne('UserModel','user_id','user_id')->bind(['nickname'=>'nickname']);
    }

    public function goods()
    {
        return $this->hasMany('OrderGoodsModel','order_id','order_id');
    }

    public static function getOne($order_id)
    {
        return self::with('user')->with('goods')->where('order_id',$order_id)->find();
    }

    public static function getList($map)
    {
        return self::order('order_id desc')->where($map)->paginate(20);
    }

    public static function updateStatus($order_id, $data)
    {
        return self::where('order_id', $order_id)->update($data);
    }

}